/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.com.losalpes.marketplace.pirfb.entities.test;

/**
 *
 * @author leon
 */
import co.com.losalpes.marketplace.pirfb.bos.IntencionBO;
import co.com.losalpes.marketplace.pirfb.entities.Intencion;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
import javax.annotation.PostConstruct;

public class InicializarIntencionBO {

    //5
    //5
    public static final String[] categorias = {"Ropa", "Alimentos", "Celulares", "Computadores", "Calzado"};
    public static final String[] ropa = {"Camiseta", "Pantalon", "Medias", "Chaqueta", "Buzo"};
    public static final String[] alimentos = {"Pollo", "Leche", "Huevos", "Cerdo", "Galletas"};
    public static final String[] celulares = {"Nokia", "Xpiria 11", "Samsung Galaxy 1", "HTC One", "Motorla Razr"};
    public static final String[] computadores = {"Lenovo ", "Toshiba", "Compaq", "HP", "Sony"};
    public static final String[] calzado = {"Tenis", "Zapatos", "Chancletas", "Zapatillas", "Botas"};
    public static final String[][] productos = {ropa, alimentos, celulares, computadores, calzado};
    private static Random ranGen = new Random();
    private static List<IntencionBO> intencionBOs = new ArrayList<IntencionBO>();

    /**
     * Inserta xx elementos en tabla cotizacion
     *
     * @param args
     */
    public static void main(String args[]) {
        init();
    }

    @PostConstruct
    private static void init() {
        Intencion intencion;
        //crear intenciones de venta y de compra
        for (int i = 0; i < 50; i++) {
            intencion = incializarIntencion();
            intencionBOs.add(intencion.toBo());
        }
    }

    private static Intencion incializarIntencion() {
        Intencion c = new Intencion();
        String seq = "INT" + System.currentTimeMillis();
        c.setNumero(seq);
        c.setNit(ranGen.nextInt(20) + "");
        c.setUser(c.getNit());
        c.setEstado(Intencion.E_ABIERTA);
        c.setTipo(ranGen.nextBoolean() ? Intencion.T_COMPRA : Intencion.T_VENTA);
        int cat = ranGen.nextInt(4);
        c.setCategoria(categorias[cat]);
        c.setProducto(productos[cat][ranGen.nextInt(4)]);
        c.setCantidad(ranGen.nextInt(50));
        int month = ranGen.nextInt(2) + 10;
        int day = ranGen.nextInt(30);
        c.setFecha_entrega(new Date(113, month, day));
        c.setFecha_max_espera(new Date(113, month + ranGen.nextInt(1), day + ranGen.nextInt(15) + 15));
        c.setValor(ranGen.nextInt(20) * 5000);
        return c;
    }

    public static Random getRanGen() {
        return ranGen;
    }

    public static void setRanGen(Random ranGen) {
        InicializarIntencionBO.ranGen = ranGen;
    }

    public static List<IntencionBO> getIntencionBOs() {
        return intencionBOs;
    }

    public static void setIntencionBOs(List<IntencionBO> intencionBOs) {
        InicializarIntencionBO.intencionBOs = intencionBOs;
    }
}
